from django.db import models

# Create your models here.
from demo_common_module.models import BaseModel


class RoleUsers(BaseModel):
    role_id = models.IntegerField(default=0, verbose_name="角色id")
    user_id = models.CharField(max_length=30, blank=True, verbose_name="用户id")

    class Meta:
        db_table = "tb_role_user"


class User(BaseModel):
    STATUS_LIST = (
        ("512", "512"),  # 启用
        ("514", "514"),  # 禁用
        ("66048", "66048"),  # 启用并密码永不过期
        ("66050", "66050"),  # 禁用
    )

    user_id = models.CharField(max_length=100, null=True, verbose_name="用户id")
    user_name = models.CharField(max_length=100, blank=True, verbose_name="用户名")
    location = models.CharField(max_length=100, blank=True, verbose_name="基地")
    department = models.CharField(max_length=100, blank=True, verbose_name="部门")
    status = models.CharField(max_length=10, verbose_name="用户的状态")
    company = models.CharField(max_length=100, blank=True, verbose_name="公司")
    display_name = models.CharField(max_length=300, blank=True, verbose_name="中英文名字")
    mail = models.CharField(max_length=300, blank=True, verbose_name="mail")
    mobile = models.CharField(max_length=30, blank=True, verbose_name="mobile")

    class Meta:
        db_table = "tb_user"


class Role(BaseModel):
    name = models.CharField(max_length=50, default="普通用户", verbose_name="角色名")
    create_user = models.CharField(max_length=50, default="admin", verbose_name="创建人")

    class Meta:
        db_table = "tb_role"


class Permission(BaseModel):
    TYPE_CHOICE = (
        ("get", "get"),
        ("post", "post"),
        ("put", "put"),
        ("delete", "delete"),
    )
    parent_id = models.IntegerField(default=0, verbose_name="父id")
    title = models.CharField(max_length=50, blank=True, verbose_name="title")
    url = models.CharField(max_length=50, default="/", verbose_name="url")
    name = models.CharField(max_length=50, default="None", blank=True, verbose_name="url别名")
    icon = models.CharField(max_length=50, default="None", blank=True, verbose_name="图标")
    weight = models.IntegerField(default=0, verbose_name="权重排序")
    type_name = models.CharField(max_length=50, choices=TYPE_CHOICE, default="get", verbose_name="图标")

    class Meta:
        db_table = "tb_permission"


class RolePermissions(BaseModel):
    """关联的都是三级菜单权限的id"""
    role_id = models.IntegerField(default=0, verbose_name="角色id")
    permission_id = models.IntegerField(default=0, verbose_name="权限id")

    class Meta:
        db_table = "tb_role_permissions"
